<?php
namespace app\admin\controller;

use app\common\controller\BaseAdmin;
use app\common\model\SystemAdmin;
use app\common\model\Grade as GradeModel;
use Illuminate\Support\Arr;
use LiteAdmin\Tree;
use think\Db;
use think\facade\Cache;
use think\facade\Session;

/**
 * @title 会员等级
 * Class Index
 * @package app\admin\controller
 */
class Grade extends BaseAdmin
{
    /**
     * @title 会员等级
     * @auth 0
     * @return mixed
     * @throws \throwable
     */
    public function index()
    {
        $db = GradeModel::alias('u')

            ->field('u.*')
            ->order('id desc');

        $search = $this->request->get();
        // 精准查询
        foreach (['status'] as $field){
            if (isset($search[$field]) && $search[$field] !== ''){
                $db->where('r.'.$field,'=', $search[$field]);
            }
        }
        // 模糊查询
        foreach (['uname'] as $field){
            if (isset($search[$field]) && $search[$field] !== ''){
                $db->whereLike('u.'.$field, "%{$search[$field]}%");
            }
        }
        return $this->_list($db, true, $search);
    }
    /**
     * @title 添加操作
     * @return array|mixed
     */
    public function add()
    {
        return $this->_form(new GradeModel(), 'form');
    }

    /**
     * @title 编辑操作
     * @return array|mixed
     */
    public function edit()
    {
        return $this->_form(new GradeModel(), 'form');
    }
    /**
     * @title 删除
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function del()
    {
        $ids = $this->request->post('ids');



        $this->_del(new GradeModel(), $ids);
    }
}
